<template>
	<view class="userName">
		<view class="imgdiv">
			<image class="img" src="../../static/login/logo.png" mode=""></image>
		</view>
		<view class="jianjie">
			百万放送 一分抢购
		</view>
		<view class="touxiang">
			授权微信昵称和头像
		</view>
		<view class="fuwu">
			更方便团长为您服务哦～
		</view>

		<button open-type="getUserInfo" @getuserinfo="getUserInfo" class="anniu">立即授权</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			};
		},
		methods: {
			getUserInfo(e) {
				// 
				const that = this;
				that.$api
					.request('user', 'updateUser', {
						userId: uni.getStorageSync('userInfo').id,
						token: uni.getStorageSync('userInfo').accessToken,
						nickName: e.detail.userInfo.nickName,
						avatarUrl: e.detail.userInfo.avatarUrl
					})
					.then(res => {
						uni.setStorageSync('userInfo', res.data)
						that.$store.commit('login', res.data)
						//新人登录，如果邀请码则跳到抢购券页面
						uni.navigateTo({
							url: "/pagesA/xinrenzhuanxing/xinrenzhuanxing"
						})
						// if (that.$store.state.InvitationCode) {
						// 	setTimeout(function() {
						// 		uni.reLaunch({
						// 			url: '/pagesA/PanicBuying/PanicBuying'
						// 		})
						// 	}, 800);
						// 	that.$store.commit('setStorageCode', '')
						// } else {
						// 	uni.switchTab({
						// 		url: '../index/indexs'
						// 	})
						// }
					});
			}
		}
	}
</script>

<style lang="scss">
	.userName {
		width: 750rpx;
		height: 100%;

		.anniu {

			margin: auto;
			margin-top: 96rpx;
			width: 440rpx;
			height: 80rpx;
			background: linear-gradient(135deg, #A2DC3F 0%, #65CB2F 100%);
			border-radius: 40rpx;

			font-size: 36rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}

		.fuwu {
			text-align: center;
			margin-top: 8rpx;
			font-size: 26rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #666666;
		}

		.touxiang {
			text-align: center;
			margin-top: 80rpx;
			font-size: 36rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 600;
			color: #666666;
		}

		.jianjie {
			text-align: center;
			margin-top: 34rpx;
			font-size: 28rpx;
			font-family: HYQiuShi-W, HYQiuShi;
			font-weight: normal;
			color: #666666;
		}

		.imgdiv {
			width: 750rpx;
			height: 200rpx;
			margin-top: 200rpx;
			display: flex;
			justify-content: center;

			.img {
				width: 200rpx;
				height: 200rpx;
			}
		}
	}
</style>
